12. Solution: TVTime
Solution Explanation
Correct Answer: Call the delete method on the ContentResolver
If you are trying to specify the "action" you’re performing on the data, you must pick the correct method you call on the ContentResolver. For this removing TV shows example, the code might look like this:
ContentResolver resolver = getContentResolver();
resolver.delete(TVTimeContract.CONTENT_URI, null, null);
Why the Other Answers Were Incorrect
Incorrect Answer: Change the content authority to allow for deleting and Change the contract class to create a URI for deleting
There are a few reasons why the first two answers are incorrect. If you are using a content provider, the contract class and the authority will be provided for you so that you can use them. You cannot change what the content authority or the contract class is. You’re essentially using someone else’s API to grab data, and you don’t have control over the format the API expects.
Also, you don’t encode the “action” you’re trying to take in the URI; again, that is reserved for the method you call on the ContentResolver
Incorrect Answer: Add the READ permission for the Content Provider
It’s possible you’ll need to add permissions, but in this case, since you’re doing a delete action (which is writing to the content provider) the permission needed would be a WRITE permission.